<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
<style type="text/css">
div table tr td{
font-family: '微软雅黑';
font-size: 15px;
}
</style>
<script type="text/javascript">
function checkEmail() {
	var userId=$("#userId").val();
	var userEmail=$("#userEmail").val();
	if(userEmail==null||userEmail==""){
		 $("#emailError").text("邮箱不能为空"); 
		}
	var reg=/^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,5}$/; 
	if(reg.test(userEmail)){
	$.ajax({
		type:'get',
		url:'user_checkEmail',
		data:{userId:userId,userEmail:userEmail},
		dataType:'json',
		 success: function(data){
            //alert(data.msg);
	            $("#emailError").text(data[0].msg);
			 }
		});
	}else{
		 $("#emailError").text("邮箱不合法；");
		}
}
function checkName(){
	var userId=$("#userId").val();
	var userName=$("#userName").val();
	if(userName==null||userName==""){
		 $("#nameError").text("用户名称不能为空");
		}else{
	$.ajax({
		type:'get',
		url:'user_checkName',
		data:{userId:userId,userName:userName},
		dataType:'json',
		 success: function(data){
            //alert(data.msg);
	            $("#nameError").text(data[0].msg);
			 }
		});
}
}
function checkPwd(){
	var password=$("#userPwd").val();
	if(password==null||password==""){
		 $("#passwordError").text("密码不能为空");
		}
	if(password.length>9||password.length<6){
		 $("#passwordError").text("密码长度是6到10位");
		}
}
function checkReplacePwd(){
	var password=$("#userPwd").val();
    var repalcePwd=$("#replacePwd").val();
    if(password!=repalcePwd){
        $("#replacePwdError").text("两次密码输入不一致");
        }
}
</script>
</head>
<body>
<s:form action="user_saveUser" method="post" theme="simple" id="save">
  <s:hidden name="user.userId"  value='%{user.userId}' id="userId"></s:hidden>
  <s:hidden name="user.type"  value='%{user.type}' ></s:hidden>
  <s:hidden name="user.created" value='%{user.created}'></s:hidden> 
 <div style="width: 500px;height: 330px;background-color: #f0f8ff ;margin: 0px auto;">
<table>
<tr height="40px;">
<td width="120px">注册邮箱：</td>
<td width="150px"><s:textfield name="user.userEmail" style="width:100%;height:100%" required="true"  theme="simple" id="userEmail" onBlur="checkEmail()" placeholder="请输入登录邮箱" value="%{user.userEmail}"></s:textfield>
</td>
<td width="200px;" id="emailError"></td>
</tr>
<tr height="40px;">
<td width="120px">昵称：</td>
<td width="150px"><s:textfield name="user.userName" required="true"  style="width:100%;height:100%" id="userName" onBlur="checkName()"  placeholder="用户昵称" value="%{user.userName}"></s:textfield> </td>
<td width="200px;"  id="nameError" ></td>
</tr>
<tr height="40px;">
<td width="120px">真实姓名：</td>
<td width="150px"><s:textfield name="user.realName" required="true" style="width:100%;height:100%" id="realName"  placeholder="真实姓名" value="%{user.realName}"></s:textfield> </td>
<td width="200px;" ></td>
</tr>
<tr height="40px;">
<td width="120px">性别：</td>
<td width="150px"><input type="radio" name="user.gender" value="1"  checked="checked"/>男<input type="radio" name="user.gender" value="0" />女</td>
<td width="200px;"></td>
</tr>
<tr height="40px;">
<td width="120px">密码：</td>
<td width="150px"><s:password name="user.userPwd" id="userPwd" style="width:100%;height:100%" placeholder="请输入登录密码" onBlur="checkPwd()" required="true" maxlength="9" ></s:password></td>
<td width="200px;" id="passwordError"></td>
</tr>
<tr height="40px;">
<td width="120px">再次输入密码：</td>
<td width="150px"><s:password name="" id="replacePwd" style="width:100%;height:100%" placeholder="请再次输入登录密码" onBlur="checkReplacePwd()" required="true" maxlength="8" ></s:password> </td>
<td width="200px;" id="replacePwdError"></td>
</tr>
<tr height="40px;">
<td width="120px">地址：</td>
<td width="380px" colspan="2"><%@ include file="/page/common/address.jsp" %></td>
</tr>
<tr height="40px;">
<td width="120px">用户手机：</td>
<td width="150px"><s:textfield name="user.userPhone" required="true"  style="width:100%;height:100%" id="userPhone"  placeholder="联系电话" value="%{user.userPhone}" ></s:textfield> </td>
<td width="200px;" id="nameError"></td>
</tr>
</table>

</div>
</s:form>
</body>
</html>